package com.gem.day08.interfaces3;

import static com.gem.day08.interfaces3.VehicleFactory.*;

import org.junit.Test;

public class VehicleTest {
	@Test
	public void test() {
		Vehicle v1 = getVehicle(CAR);
		v1.setDirection("西");
		v1.setSpeed(90);
		v1.move();

		Vehicle v2 = getVehicle(PLANE);
		v2.setDirection("东");
		v2.setSpeed(900);
		v2.move();

		Vehicle[] vehicles = new Vehicle[] { v1, v2 };
		for (Vehicle v : vehicles) {
			if (v instanceof ICheckSpeed) {
				if (v.getSpeed() > 80) {
					System.out.println("对不起,超速了!");
				} else {
					v.move();
				}
			} else {
				v.move();
			}
		}
	}
}
